package Demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-05-24
 * Time: 21:39
 */
public class Test {
    public static void main(String[] args) {
        Traingle traingle = new Traingle();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        Shape[] shapes = {traingle,traingle,cycle,cycle,flower};

        for(Shape shape:shapes) {
            shape.draw();
        }
        System.out.println("-等价于-");
        for (int i = 0; i < shapes.length; i++) {
            Shape shape = shapes[i];
            shape.draw();
        }
    }
    public static void main2(String[] args) {
        Traingle traingle = new Traingle();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();

        String strings[] ={ "traingle","traingle","cycle","cycle","flower"};
        for(String s: strings) {
            if (s.equals("traingle")){
                traingle.draw();
            }else if (s.equals("cycle")) {
                cycle.draw();
            }else {
                flower.draw();
            }
        }
    }
    public static void fuc(Shape shape) {
        shape.draw();
    }
    public static void main1(String[] args) {
        Traingle traingle = new Traingle();
        Cycle cycle = new Cycle();
        Flower flower = new Flower();
        fuc(traingle);
        fuc(cycle);
        fuc(flower);
    }
}
